// Source table layout definition, the data are in CarsData.xml 
TreeGridLoaded ({ /* JSONP header, to be possible to load from xxx_Jsonp data source */ 
   "Cfg" : { "id": "Cars", "SuppressCfg": "0"   },  // Base definition, saves configuration to cookies 
   "Cfg_2" : { "Size": "Low"   },  // Smaller size for large grid 
   "Cfg_3" : { "MaxHeight": "1", "MinTagHeight": "400"   },  // Size settings just for the example. Maximizes the grid height. 
   "Cfg_4" : { "Sort": "BRAND,NAME"   },  // Predefined sorting 
   "Cfg_5" : { "AutoSort": "1"   },  // Automatically sorts row after edited cell in sorted column, including added or changed rows by pivot editing 
   "Cfg_6" : { "Paging": "2"   },  // Client paging with pager 
   "Pager" : { "Width": "200", "MinWidth": "150"   },  // Width of the right pager 
   "Cfg_7" : { "LimitScroll": "23", "MinBodyRows": "6", "MinMidWidth": "500"   },   // Responsive design, for small windows sets NoVScroll and NoHScroll 
   "Cfg_8" : { "ImportRows": "3"   },  // Permits importing rows data from exported xlsx, accepts only xlsx exported by this sample 
   "Cfg_9" : { "ExportType": "Outline,ForceBorder,HideFiltered,HideGroupCols,Hidden,Hide,FixedRows,FixedCols,TreeGrid,ColNames,RangeComment"   },  // Settings for xlsx export, support also for importing xlsx back 

   // Default column for YEAR, MONTH and DAY 
   "DefCols" : [ 
      { "Name": "DATESOURCE", "Visible": "0", 
         "OnChange": "var y=Get(Row,'YEAR'),m=Get(Row,'MONTH'),d=Get(Row,'DAY');Grid.SetValue(Row,'DATE',Date.UTC(y?y:2013,m?{January:1,February:2,March:3,April:4,May:5,June:6,July:7,August:8,September:9,October:10,November:11,December:12}[m]-1:0,d?d:1),1);"  
          }  
   ], 

   // Clears formulas for group rows that are used in pivot calculation 
   "Def" : [ 
      { "Name": "Group", "YEARFormula": "", "QUARTERFormula": "", "MONTHFormula": "", "DAYFormula": "", "WEEKFormula": "", "WEEKDAYFormula": ""   }  
   ], 

   // Columns definitions 
   "Cols" : [ 
      { "Name": "BRAND"   }, 
      { "Name": "TYPE"   }, 
      { "Name": "NAME"   }, 
      { "Name": "MODEL", "Width": "100"   }, 
      { "Name": "TRANS"   }, 
      { "Name": "COLOR"   }, 
      { "Name": "COUNT", "Type": "Float"   }, 
      { "Name": "PRICE", "Type": "Float"   }, 
      { "Name": "TOTAL", "Type": "Float", "Formula": "PRICE*COUNT"   }, 
      { "Name": "DATE", "Type": "Date", "Format": "dddd, dddddd MMMM yyyy"   }, 
      { "Name": "YEAR", "Formula": "DateToString(DATE,'yyyy')", "Def": "DATESOURCE"   }, 
      { "Name": "QUARTER", "Formula": "DateToString(DATE,'MMMMM')", "Type": "Enum", "Enum": "|I|II|III|IV", "RawSort": "2", "Visible": "0"   }, 
      { "Name": "MONTH", "Formula": "DateToString(DATE,'MMMM')", "Type": "Enum", "Enum": "|January|February|March|April|May|June|July|August|September|October|November|December", "RawSort": "2", "Def": "DATESOURCE"   }, 
      { "Name": "DAY", "Formula": "DateToString(DATE,'dd')", "Def": "DATESOURCE"   }, 
      { "Name": "WEEK", "Formula": "var d=DateToString(DATE,'ddddddd'); return 'Week '+(d<10?'0'+d:d)", "Visible": "0"   }, 
      { "Name": "WEEKDAY", "Formula": "DateToString(DATE,'dddd')", "Type": "Enum", "Enum": "|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "RawSort": "2", "Visible": "0"   }  
   ], 

   // Filter definition 
   "Head" : [ 
      { "Kind":"Filter", "BRANDButton": "Defaults", "BRANDDefaults": "|*FilterOff|*RowsAll", "BRANDRange": "1", "BRANDShowMenu": "0", 
              "TYPEButton": "Defaults", "TYPEDefaults": "|*FilterOff|*RowsAll", "TYPERange": "1", "TYPEShowMenu": "0", 
              "NAMEButton": "Defaults", "NAMEDefaults": "|*FilterOff|*RowsAll", "NAMERange": "1", "NAMEShowMenu": "0", 
              "MODELButton": "Defaults", "MODELDefaults": "|*FilterOff|*RowsAll", "MODELRange": "1", "MODELShowMenu": "0", 
              "TRANSButton": "Defaults", "TRANSDefaults": "|*FilterOff|*RowsAll", "TRANSRange": "1", "TRANSShowMenu": "0", 
              "COLORButton": "Defaults", "COLORDefaults": "|*FilterOff|*RowsAll", "COLORRange": "1", "COLORShowMenu": "0"  
               }  
   ], 

   // Hides useless toolbar buttons 
   "Toolbar" : { "Sort": "0", "Calc": "0"   }, 

   // The solid rows are nearly the same as in Pivot table - to set up the pivot if the pivot is hidden 
   // It differs only in control buttons in the third row and their function 
   "Solid" : [ 
      { "id": "LIST", "Kind": "Topbar2", "Panel": "0", "Space": "0", "Cells": "COLS1,COLS2,COLS3", 
         "COLS1Type": "DropCols", "COLS1": "BRAND,TYPE,NAME,MODEL,TRANS,COLOR", 
         "COLS1RelWidth": "6", "COLS1MaxWidth": "100", "COLS1AutoWidth": "7", "COLS1MinTextWidth": "0", "COLS1Text": "", "COLS1CanAdd": "0", "COLS1CanDelete": "0", "COLS1CanMove": "0", "COLS1CanCopy": "2", "COLS1ShowHint": "0", 
         "COLS2Type": "DropCols", "COLS2": "YEAR,QUARTER,MONTH,DAY,WEEK,WEEKDAY", 
         "COLS2RelWidth": "6", "COLS2MaxWidth": "100", "COLS2AutoWidth": "7", "COLS2MinTextWidth": "0", "COLS2Text": "", "COLS2CanAdd": "0", "COLS2CanDelete": "0", "COLS2CanMove": "0", "COLS2CanCopy": "2", "COLS2ShowHint": "0", 
         "COLS3Type": "DropCols", "COLS3": "PRICE,COUNT,TOTAL", 
         "COLS3RelWidth": "3", "COLS3MaxWidth": "100", "COLS3AutoWidth": "7", "COLS3MinTextWidth": "0", "COLS3Text": "", "COLS3CanAdd": "0", "COLS3CanDelete": "0", "COLS3CanMove": "0", "COLS3CanCopy": "2", "COLS3ShowHint": "0"  
          }, 
      { "id": "PIVOT", "Kind": "Topbar1", "Space": "0", "Cells": "RCAP,ROWS,CCAP,COLS,DCAP,DATA", 
         "RCAPType": "Html", "RCAP": "Pivot Rows:", "RCAPWrap": "0", 
         "ROWSType": "DropCols", "ROWSRelWidth": "1", "ROWSText": "Drag column caption here", "ROWSFormula": "Grids.Pivot.PivotRows?Grids.Pivot.PivotRows:''", "ROWSOnChange": "Grids.Pivot.PivotRows = Value", 
         "ROWSAccept": "BRAND,TYPE,NAME,MODEL,TRANS,COLOR,YEAR,QUARTER,MONTH,DAY,WEEK,WEEKDAY", "ROWSDuplicates": "0", "ROWSSingle": ",COLS,,DATA", "ROWSSingleType": "1", 
         "CCAPType": "Html", "CCAP": "Columns:", "CCAPLeft": "10", 
         "COLSType": "DropCols", "COLSRelWidth": "1", "COLSText": "Drag column caption here", "COLSFormula": "Grids.Pivot.PivotCols?Grids.Pivot.PivotCols:''", "COLSOnChange": "Grids.Pivot.PivotCols = Value", 
         "COLSAccept": "BRAND,TYPE,NAME,MODEL,TRANS,COLOR,YEAR,QUARTER,MONTH,DAY,WEEK,WEEKDAY", "COLSDuplicates": "0", "COLSSingle": ",ROWS,,DATA", "COLSSingleType": "1", 
         "DCAPType": "Html", "DCAP": "Data:", "DCAPLeft": "10", 
         "DATAType": "DropCols", "DATARelWidth": "1", "DATAText": "Drag column caption here", "DATAFormula": "Grids.Pivot.PivotData?Grids.Pivot.PivotData:''", "DATAOnChange": "Grids.Pivot.PivotData = Value", 
         "DATAAccept": "BRAND,TYPE,NAME,MODEL,TRANS,COLOR,YEAR,QUARTER,MONTH,DAY,WEEK,WEEKDAY,PRICE,COUNT,TOTAL", "DATADuplicates": "0", "DATASingle": ",ROWS,,COLS", "DATASingleType": "1"  
          }, 
      { "id": "CONTROL", "Kind": "Topbar2", "Space": "0", "Cells": "PIVOT,SWITCH,ALL,CLEAR,SUM,DEF", "Calculated": "1", "CalcOrder": "SUM,DEF,SWITCHVisible,ALL,ALLVisible,CLEARVisible", 
         "PIVOTType": "Button", "PIVOTButton": "Button", "PIVOT": "Create pivot", "PIVOTOnClick": "if(!Grids.Pivot.CreatePivot()) alert('Incorrect or incomplete input settings');", 
         "SWITCHType": "Button", "SWITCHButton": "Button", "SWITCH": "Show pivot", "SWITCHOnClick": "Grids.Pivot.SwitchPivotGrid(1);", "SWITCHVisibleFormula": "Grids.Pivot.PivotData?1:0", 
         "ALLType": "Button", "ALLButton": "Button", "ALL": "Show both", "ALLFormula": "Grids.Pivot.MainTag.style.display=='none' ? 'Show both' : 'Show master'", "ALLOnClick": "Grids.Pivot.SwitchPivotGrid(Grids.Pivot.MainTag.style.display=='none'?2:0);", "ALLVisibleFormula": "Grids.Pivot.PivotData?1:0", 
         "CLEARType": "Button", "CLEARButton": "Button", "CLEAR": "Clear pivot", "CLEAROnClick": "Grids.Pivot.PivotRows=''; Grids.Pivot.PivotCols=''; Grids.Pivot.PivotData=''; Grids.Pivot.CreatePivot(); return 1;", "CLEARVisibleFormula": "Grids.Pivot.PivotData?1:0", 
         "SUMType": "Bool", "SUMLabel": "Show summary columns", "SUMLeft": "10", "SUMFormula": "Grids.Pivot.PivotShowParent?1:0", "SUMCanEdit": "1", 
         "SUMOnChange": "Grids.Pivot.PivotShowParent = Value; Grids.Pivot.CreatePivot(); ", "SUMTip": "If the summary columns are hidden, their data are shown when the column is collapsed.", 
         "DEFType": "SelectPivot", "DEFLeft": "10", "DEFLabel": "Predefined pivots:", "DEFRelWidth": "1", "DEFCanEdit": "1", 
         "DEFDefaults": "|BRAND,TYPE,NAME,MODEL : YEAR,MONTH,WEEK,WEEKDAY : TOTAL|YEAR,MONTH,WEEK,WEEKDAY : BRAND,TYPE,NAME,MODEL : TOTAL|BRAND,TYPE,NAME,MODEL : YEAR,MONTH : PRICE,COUNT|TYPE,BRAND : YEAR,MONTH : NAME|NAME : WEEKDAY : COUNT|NAME : TRANS : COLOR|WEEKDAY : BRAND,NAME : COLOR|YEAR,QUARTER,MONTH : BRAND,NAME : TOTAL|YEAR,MONTH,DAY : BRAND,TYPE,NAME : TRANS,COLOR|MONTH,DAY : NAME : PRICE,COUNT|BRAND : YEAR : TOTAL"  
          }  
   ], 
}) /* End of JSONP header */ 